﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CLUBsInterpreter.ObjectTypes
{
	/**
	 * <summary>
	 * Describes a player object in the CLUBs environment.
	 * </summary>
	 **/
	class CLUBsPlayer : CLUBsObject
	{
		private static int s_nextPrototypeID = 0;

		public int PrototypeID = -1;
		/**
		 * <summary>
		 * Default constructor creates player with default properties.
		 * </summary>
		 **/
		public CLUBsPlayer(bool newProto = false)
		{
			if (newProto) PrototypeID = s_nextPrototypeID++;
			// Set the object identifier type
			ObjectIdentifierType = AST.IdentifierType.Player;
			// SPECIFY STANDARD ENVIRONMENT
			// Main piece variable specifying the piece this player uses
			LocalVariables.Declare("MainPiece", new CLUBsPiece());
			// Boolean defining whether the player has won
			LocalVariables.Declare("HasWon", new CLUBsBoolean(false));
			// Boolean defining whether the player has lost
			LocalVariables.Declare("HasLost", new CLUBsBoolean(false));
		}

		/**
		 * <see cref="CLUBsObject.CopyValueFromObject"/>
		 **/
		public override void CopyValueFromObject(CLUBsObject obj)
		{
            /*CLUBsPlayer playerObj = (CLUBsPlayer)obj;
            LocalVariables.Clear();

            foreach (KeyValuePair<string, CLUBsObject> var in playerObj.LocalVariables)
            {
				LocalVariables.Add(var.Key, var.Value);
				LocalVariables[var.Key].CopyValueFromObject(var.Value);
            }*/

			////  !!! WE NEVER COPY VALUE OF PLAYERS BECAUSE THEY ARE ALWAYS REFERENCE TYPES! :O
		}
		public override string ToString()
		{
			return Name;
		}
	}
}
